package com.bush.mall.product.controller;

import com.bush.mall.product.entity.dto.AttrGroupDTO;
import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.product.entity.AttrGroupEntity;
import com.bush.mall.product.service.AttrGroupService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

/**
 * 属性分组
 * @author RUN
 * @date 2022-12-11
 */
@RestController
@RequestMapping("product/attrgroup")
@Api(tags = "属性分组管理" )
public class AttrGroupController {

    @Resource(name= AttrGroupService.BEAN_ID)
    private AttrGroupService attrGroupService;

    @ApiOperation(value = "分页查询属性分组列表")
    @GetMapping("queryForPage")
    public Result queryForPage(AttrGroupDTO dto){
        return attrGroupService.queryForPage(dto);
    }

    @ApiOperation(value = "根据属性id查询分组记录")
    @GetMapping("{id}")
    public Result queryById(@PathVariable Long id){
        return attrGroupService.queryById(id);
    }


    @ApiOperation(value = "保存属性分组表单")
    @PostMapping
    public Result saveAttrGroup(@RequestBody AttrGroupEntity attrGroup){
        return attrGroupService.saveAttrGroup(attrGroup);
    }


    @ApiOperation(value = "修改属性分组表单")
    @PutMapping
    public Result updateAttrGroup(@RequestBody AttrGroupEntity attrGroup){
        return attrGroupService.updateAttrGroup(attrGroup);
    }


    @ApiOperation(value = "通过ids批量删除属性分组")
    @DeleteMapping
    public Result deleteAttrGroup(@RequestBody List<Long> ids){
        return attrGroupService.deleteAttrGroup(ids);
    }

}
